//
//  HikeDetail.swift
//  SwiftUi
//
//  Created by xm on 02/09/2025.
//

import SwiftUI


struct HikeDetail: View {
    var hike: Hike
    @State private var dataToShow = \Hike.Observation.elevation
    
    var buttons = [
        ("还把", \Hike.Observation.elevation),
        ("心率", \Hike.Observation.heartRate),
        ("步伐", \Hike.Observation.pace),
    ]

    var body: some View {
        VStack {
            HikeGraph(hike: hike, path: dataToShow)
                .frame(height: 200, alignment: .center)
            
            HStack(spacing: 25) {
                ForEach(buttons, id: \.0) { value in
                    Button(action:{
                        self.dataToShow = value.1
                    }) {
                        Text(verbatim: value.0).font(.system(size: 15))
                            .foregroundColor(value.1 == self.dataToShow ? .gray : .accentColor)
                            .animation(nil)
                    }
                    
                }
            }
            
        }
    }
}

#Preview {
    HikeDetail(hike: hikes[0])
}
